/*
* @Author: Administrator
* @Date:   2018-09-14 19:44:50
* @Last Modified by:   Administrator
* @Last Modified time: 2018-09-15 09:43:14
*/

import axios from 'axios';
import * as constants from './constants.js';

const changeLogin = (result) => ({
	type: constants.CHANGE_LOGIN,
	result
})
export const logout = () => ({
    type: constants.LOGOUT_DATA
})
export const login =  (account, password) => {
	return (dispatch) => {
    axios.get('./api/login.json?account=' + account + '&password=' + password).then((res) => {
    	const result = res.data.data; 
    	if (result) {
    		dispatch(changeLogin(result));
    	}
    	else {
    		alert('登录失败');
    	}
    })
	}
}